********* Table A12 *********
clear all
set more off 
capture log close
 
* main path to data
global path "~/Dropbox/Paraguay/1_data/7_replication_dataverse"
capture cd "$path"	

*tables = analysis tables
global tables "$path/tables"

* Load and prepare data
use "$path/data/anr.dta", clear
xtset district_code periods



forval i = 1/9 {
    generate p`i' = (periods == `i')
}

// Generate the 'alt_p' variable and set it to 0
generate alt_p = 0



set more off
eststo clear


	reghdfe l_anr ///
    i.p1##c.lambda_z ///
    p2##c.lambda_z ///
    p3##c.lambda_z ///
    p4##c.lambda_z ///
    p5##c.lambda_z ///
    p6##c.lambda_z ///
    alt_p ///
    p8##c.lambda_z ///
    p9##c.lambda_z, absorb(periods district_code periods#depa) cluster(district_code) nocons

	eststo


capture cd "tables"
esttab est* using "tableA12.tex", replace nonumber label style(tex) ///
		cells(b(star fmt(%12.4fc)) se(par fmt(%12.4fc))) ///
		stats( N r2 , fmt( %12.0fc %12.4fc ) ///
			label("\hline Observations"  ///
			  "\$R^2\$" )) ///
		keep( 1.p1#c.lambda_z 1.p2#c.lambda_z 1.p3#c.lambda_z 1.p4#c.lambda_z 1.p5#c.lambda_z ///
     1.p6#c.lambda_z  1.p8#c.lambda_z 1.p9#c.lambda_z ) ///	
		order(1.p1#c.lambda_z 1.p2#c.lambda_z 1.p3#c.lambda_z 1.p4#c.lambda_z 1.p5#c.lambda_z ///
     1.p6#c.lambda_z  1.p8#c.lambda_z 1.p9#c.lambda_z ) ///
		varlabels(1.p1#c.lambda_z "1959-1963 \$\times\$ Largest Eigenvalue" 1.p2#c.lambda_z "1964-1968 \$\times\$ Largest Eigenvalue" ///
		1.p3#c.lambda_z "1969-1973 \$\times\$ Largest Eigenvalue" 1.p4#c.lambda_z "1974-1978 \$\times\$ Largest Eigenvalue" ///
		1.p5#c.lambda_z "1979-1983 \$\times\$ Largest Eigenvalue" ///
     1.p6#c.lambda_z  "1984-1988 \$\times\$ Largest Eigenvalue" 1.p8#c.lambda_z "1994-1998 \$\times\$ Largest Eigenvalue" ///
	 1.p9#c.lambda_z "1999-2003 \$\times\$ Largest Eigenvalue") ///	
		collabels(, none) eqlabels(, none) starlevels(* 0.1 ** 0.05 *** 0.01) ///
		prehead(\begin{tabular}{l*{@M}{c}} \hline ///
			&  \multicolumn{1}{c}{Colorado Party Affiliations (log)}   \\ ///
			& (1)    \\)  ///
		posthead(\hline ) mlabels(, none) ///
		prefoot( ) postfoot(\hline \end{tabular})
	
